package com.team233.zuccecho.controller;

import com.team233.zuccecho.Bean.*;
import com.team233.zuccecho.dto.QuestionnaireDto;

import com.team233.zuccecho.result.ExceptionMsg;
import com.team233.zuccecho.result.ResponseData;
import com.team233.zuccecho.service.inter.TeacherInterface;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.text.ParseException;
import java.util.List;


@RestController
@RequestMapping("v1")
public class TeacherController {
    @Autowired
    private TeacherInterface teacherInterface;

    //教师发布问卷
    @RequestMapping(value = "/releasequestionnaire")
    public ResponseData releaseQn(@RequestBody QuestionnaireDto questionnaireDto) throws ParseException, IOException {
        Long id = teacherInterface.releaseQn(questionnaireDto);
        if(id == null)
            return new ResponseData(ExceptionMsg.FAILED,null);
        else
            return new ResponseData(ExceptionMsg.SUCCESS,id);
    }

    //教师查阅自己的授课课表
    @GetMapping("teacher/clazzIfo/{tea_id}")
    public ResponseData QueryTeaClazz(@PathVariable("tea_id") String tea_id){
        List<Clazz> clazzList=teacherInterface.QueryTeaClazz(tea_id);
        return new ResponseData(ExceptionMsg.SUCCESS,clazzList);
    }

    //老师查询自己添加的问卷列表
    @GetMapping("teacher/questionnaire/{tea_id}")
    public ResponseData QueryTeaQuestionnaire(@PathVariable("tea_id") String tea_id){
        List<Questionnaire> questionnaireList =teacherInterface.QueryTeaQuestionnaire(tea_id);
        return new ResponseData(ExceptionMsg.SUCCESS, questionnaireList);
    }
    
    //老师根据问卷编号查询对应反馈
    @GetMapping("teacher/feedback/{questionnaire_id}")
    public ResponseData QueryFeedback(@PathVariable("questionnaire_id") long questionnaire_id){
        List<Feedback> feedbackList = teacherInterface.QueryFeedback(questionnaire_id);
        return new ResponseData(ExceptionMsg.SUCCESS, feedbackList);
    }
}
